<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>

<#assign css>
<style>
</style>
</#assign>
<#assign js>
<script>
	function del(id) {
		layer.confirm('确定取消?', {icon: 3, title: '取消后师傅信息将置为无效'}, function (index) {
			$.ajax({
				type: "POST",
				dataType: "json",
				url: "/master/delete/" + id,
				success: function (res) {
					layer.msg(res.message, {time: 2000}, function () {
						location.reload();
					});
				}
			});
		});
	}

	function agree(id) {
		layer.confirm('确定申请?', {icon: 3, title: ''}, function (index) {
			$.ajax({
				type: "POST",
				dataType: "json",
				url: "/master/agree/" + id,
				success: function (res) {
					layer.msg(res.message, {time: 2000}, function () {
						location.reload();
					});
				}
			});
		});
	}

	//tableId,queryId,conditionContainer
	//var userTable;
	var winId="userWin";
	$(function() {
		//init table and fill data
		//userTable = new CommonTable("user_table", "user_list", "searchDiv");

		//button event
		$('button[data-btn-type]').click(function() {
			var action = $(this).attr('data-btn-type');
			var rowId="ceshi";
			switch (action) {
				case 'add':
					modals.openWin({
						winId:winId,
						title:'新增师傅管理',
						width:'900px',
						url:"/master/edit/ceshi"
					});
					break;
				case 'edit':
					if(!rowId){
						modals.info('请选择要编辑的行');
						return false;
					}
					modals.openWin({
						winId:winId,
						title:'编辑师傅管理【'+userTable.getSelectedRowData().name+'】',
						width:'900px',
						url:"/master/edit/"+rowId,
					});
					break;
				case 'delete':
					if(!rowId){
						modals.info('请选择要删除的行');
						return false;
					}
					modals.confirm("是否要删除该行数据？",function(){
						ajaxPost(basePath+"/master/delete/"+rowId,null,function(data){
							if(data.success){
								//modals.correct("已删除该数据");
								userTable.reloadRowData();
							}else{
								modals.error("师傅管理数据被引用，不可删除！");
							}
						});
					})
					break;
			}

		});
		//form_init();
	});
</script>
</#assign>
<@layout title="师傅管理管理" active="master">
<!-- Content Header (Page header) -->

<!-- Main content -->
<section class="content">
	<!-- Default box -->
	<div class="box box-primary">
		<div class="box-header">

			<form class="form-horizontal form-edit" method="post" action="/master/index" id="form">
				<div class="form-group" style="margin-top:10px;">
<#--					<div class="col-sm-2">-->
<#--						<input  placeholder="请输入分站Id" id="agentId" name="agentId" class="form-control" type="text" value="${masterReq.agentId!}" >-->
<#--					</div>-->
					<div class="col-sm-2">
						<input  placeholder="姓名/手机号" id="masterName" name="masterName" class="form-control" type="text" value="${masterReq.masterName!}" >
					</div>
					<div class="col-sm-2">
						<@my.select id="authStatus" datas=getDict('MASTER_DATA_STATUS')  value="${masterReq.authStatus!}" defaultValue="全部"/>
					</div>
<#--					<div class="col-sm-2">-->
<#--						<@my.select id="authStatus" datas=getDict('AUTH_STATUS')  value="${masterReq.authStatus!}" defaultValue="请选择认证状态"/>-->
<#--					</div>-->
<#--					<div class="col-sm-2">-->
<#--						<@my.select id="serviceType" datas=getDict('MASTER_SERVER')  value="${masterReq.servicType!}" defaultValue="请选择服务类型"/>-->
<#--					</div>-->
				</div>
				<div class="btn-group">
					<button type="submit" class="btn btn-primary" data-btn-type="search">查询</button>
					<button type="button" class="btn btn-default" data-btn-type="reset" onclick="javascript:$('#form')[0].reset();">重置</button>
				</div>
			</form>
<#--        <@shiro.hasPermission name="system:master:add">-->
<#--			<a class="btn btn-sm btn-success" href="/master/add">新增</a>-->
<#--        </@shiro.hasPermission>-->
		</div>
		<div class="box-body">
			<table class="table table-striped">
				<tr>
					<th></th>
					<th>分站id</th>
					<th>师傅姓名</th>
					<th>服务品类</th>
					<th>总收益</th>
					<th>余额</th>
					<th>评分</th>
					<th>状态</th>
					<th>今日在线</th>
					<th>操作</th>
				</tr>
                <#list pageInfo.list as item>
                <tr>
					<td >${item.id!}</td>
					<td >${item.agentId!}</td>
					<td >${item.masterName!}</td>
					<td >${item.serviceType!}</td>
					<td >${item.totalIncome!}</td>
					<td >${item.accountBalance!}</td>
					<td >${item.score!}</td>
					<td >${convert('AUTH_STATUS',item.authStatus)!}</td>
					<td >${item.currentTimes!}</td>
					<td>
					<@shiro.hasPermission name="system:master:detail">
						<a class="btn btn-sm btn-success" href="/master/history/${item.userId}" data-btn-type="detail">历史在线</a>
					</@shiro.hasPermission>
						<@shiro.hasPermission name="system:master:detail">
							<a class="btn btn-sm btn-success" href="/master/data/${item.id}" data-btn-type="detail">数据</a>
						</@shiro.hasPermission>
					<@shiro.hasPermission name="system:master:detail">
                        <a class="btn btn-sm btn-success" href="/master/detail/${item.id}" data-btn-type="detail">编辑</a>
                    </@shiro.hasPermission>
					</td>
				</tr>
                </#list>
			</table>
		</div>
		<!-- /.box-body -->
		<div class="box-footer clearfix">
            <@macro.page pageInfo=pageInfo url="/master/index?" />
		</div>
	</div>
	<!-- /.box -->

</section>
<!-- /.content -->
</@layout>
